<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class Caravans extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $table = $this->table('caravan', array('comment' => '房车基本信息表'));
        $table
			        ->addColumn('number', 'string', array('limit' => 255,'null' => true, 'comment' => '房车编号'))
              ->addColumn('name', 'string', array('limit' => 255, 'comment' => '房车名称','null' => true))
      			  ->addColumn('car_brands_id', 'integer', array('comment' => '房车品牌ID','null' => true))
              ->addColumn('grade', 'integer', array('limit' => MysqlAdapter::INT_TINY, 'comment' => '房车等级'))
      			  ->addColumn('car_cates_id', 'integer', array('comment' => '房车车型ID','null' => true))
              ->addColumn('speed', 'integer', array('comment' => '排挡','null' => true))
              ->addColumn('driver_type', 'string', array('comment' => '准驾类型','null' => true))
              ->addColumn('registration', 'string', array('comment' => '注册日期','null' => true))
      			  ->addColumn('car_countries_id', 'integer', array('comment' => '房车国别ID','null' => true))
              ->addColumn('services', 'integer', array('comment' => '房车服务机构','null' => true))
              ->addColumn('services_other', 'string', array('limit' => 255,'comment' => '自行添加的房车服务机构','null' => true))
              ->addColumn('country', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '房车所属国家')) 
              ->addColumn('province', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '房车所属省份')) 
              ->addColumn('city', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '房车所属城市')) 
              ->addColumn('park_num', 'integer', array('comment' => '泊位编号','null' => true))
              ->addColumn('area', 'string', array('comment' => '房车所在城市地区'))
      			  ->addColumn('size', 'string', array('limit' => 255, 'comment' => '房车尺寸(长*宽*高)','null' => true))
              ->addColumn('people_num', 'integer', array('comment' => '可住人数','null' => true))
              ->addColumn('single_bed_num', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '单人床数量','null' => true))
              ->addColumn('double_bed_num', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '双人床数量','null' => true))
              ->addColumn('sofe_num', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '沙发的乘坐人数','null' => true))

              ->addColumn('kitchen', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '厨房','null' => true))
              ->addColumn('bathroom', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '卫生间','null' => true))
              ->addColumn('wifi', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '网络','null' => true))
              ->addColumn('tv', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '电视','null' => true))
              ->addColumn('washer', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '洗衣机','null' => true))
              ->addColumn('air_condition', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '空调','null' => true))
              ->addColumn('the_shower', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '淋浴器','null' => true))

              ->addColumn('extinguisher', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '灭火器','null' => true))
              ->addColumn('annunciator', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '报警器','null' => true))
              ->addColumn('monitored', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '监控器','null' => true))

              ->addColumn('integral', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '房车参考价格','null' => true))

              ->addColumn('user_id', 'integer', array('comment' => '车主ID','null' => true))
              ->addColumn('owner_name', 'string', array('limit' => 255, 'comment' => '车主姓名','null' => true))
              ->addColumn('brand_number', 'string', array('limit' => 255, 'comment' => '车牌号','null' => true))
              ->addColumn('piccaravan', 'string', array('limit' => 1000, 'comment' => '房车内容图片','null' => true))
              ->addColumn('caravancover', 'string', array('limit' => 1000, 'comment' => '房车封面图片','null' => true))
              ->addColumn('status', 'integer', array('comment' => '房车审核状态','default' => 0))
			        ->addColumn('hot', 'integer', array('default' => 0, 'limit' => MysqlAdapter::INT_TINY, 'comment' => '设置首页热门','null' => true))
              ->addColumn('branch_id', 'integer', array('comment' => '分公司ID','null' => true))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addColumn('deleted_at', 'timestamp', array('null' => true))
              
              ->addIndex('id')
              ->save();   
    }
    public function down()
    {
        $this->dropTable('caravan');
    }
}
